package com.orange.controller;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.orange.handler.AuthSchoolRunningDateService;
import com.orange.handler.AuthSchoolService;
import com.orange.modules.bean.RunningData;
import com.orange.modules.bean.SessionUser;
import com.orange.modules.entity.AuthSchoolRunningMap;
import com.orange.modules.entity.school.AuthSchool;
import com.orange.modules.entity.school_data.AuthSchoolRunningData;
import com.orange.util.ReturnCode;

@Controller
@RequestMapping("/schoolRunningDate")
public class AuthSchoolRunningDateController extends BaseController{

	private static final Logger log = Logger.getLogger(AuthSchoolRunningDateController.class);
	
	@Autowired
	private AuthSchoolRunningDateService authSchoolRunningDateService;
	
	@Autowired
	private AuthSchoolService authSchoolService;

	/**
	 * 新增办学数据
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/insertschoolRunning" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> insertschoolRunning(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		AuthSchoolRunningData asrd = new AuthSchoolRunningData();
		try{
			String schoolStartTime = map.get("schoolStartTime");
			String reorganizationTime = map.get("reorganizationTime");
			String schoolUpgradedCollegeTime = map.get("schoolUpgradedCollegeTime");
			String undergraduateSchoolTime = map.get("undergraduateSchoolTime");
			String undergraduateProfessionalStartTime = map.get("undergraduateProfessionalStartTime");
			String specialtyStartupTime = map.get("specialtyStartupTime");
			String sid = map.get("sid");
			String loginType = map.get("loginType");
			String status = map.get("status");
			String plantime = map.get("planTime");
			String planType = map.get("planType");
			
			if(schoolStartTime==null || StringUtils.isBlank(schoolStartTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校创办时间不能为空");
			/*if(reorganizationTime==null || StringUtils.isBlank(reorganizationTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校合并或重组时间");
			if(schoolUpgradedCollegeTime==null || StringUtils.isBlank(schoolUpgradedCollegeTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校由中师升格专科时间");
			if(undergraduateSchoolTime==null || StringUtils.isBlank(undergraduateSchoolTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校由专科升格本科时间");
			if(undergraduateProfessionalStartTime==null || StringUtils.isBlank(undergraduateProfessionalStartTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"本科专业开办时间");*/
			if(specialtyStartupTime==null || StringUtils.isBlank(specialtyStartupTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专科专业开办时间");
			if(sid==null || StringUtils.isBlank(sid))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校ID不能为空");
			if(loginType==null || StringUtils.isBlank(loginType))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专业类型不能为空");
			if(status==null || StringUtils.isBlank(status))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"数据状态不能为空");
			/*if(plantime==null || StringUtils.isBlank(plantime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"计划时间不能为空");
			if(planType==null || StringUtils.isBlank(planType))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"计划类型不能为空");*/
			asrd.setCreatetime(sdf.format(new Date()));
			asrd.setLoginType(loginType);
			asrd.setReorganizationTime(reorganizationTime);
			asrd.setSchoolStartTime(schoolStartTime);
			asrd.setSchoolUpgradedCollegeTime(schoolUpgradedCollegeTime);
			asrd.setSid(sid);
			asrd.setSpecialtyStartupTime(specialtyStartupTime);
			asrd.setStatus(status);
			asrd.setUndergraduateProfessionalStartTime(undergraduateProfessionalStartTime);
			asrd.setUndergraduateSchoolTime(undergraduateSchoolTime);
			authSchoolRunningDateService.insertAuthSchoolRunningData(asrd);
			if(asrd.getPid()!=null && plantime!=null && StringUtils.isNotBlank(plantime)){
				String[] plantimelist = plantime.split(",");
				String[] plantypelist = planType.split(",");
				for(int i =0;i<plantimelist.length;i++){
					AuthSchoolRunningMap asrm = new AuthSchoolRunningMap();
					asrm.setPlantime(plantimelist[i]);
					asrm.setSrid(asrd.getPid());
					asrm.setType(plantypelist[i]);
					authSchoolRunningDateService.insertRunningMap(asrm);
				}
			}
			return toResponse(asrd,ReturnCode.SUCCESS,"新增成功");
		}catch(Exception e){
			log.error(e);
			return toResponse(null,ReturnCode.FAIL,"新增失败");
		}
		
	}
	
	@RequestMapping(value = "/querySchoolRunningBySchoolId" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> querySchoolRunningBySchoolId(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		String schoolId = map.get("schoolId");
		String loginType = map.get("loginType");
		if(schoolId==null || StringUtils.isBlank(schoolId))
			return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校ID不能为空");
		if(loginType==null || StringUtils.isBlank(loginType))
			return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专业类型不能为空");
		RunningData rd = new RunningData();
		AuthSchoolRunningData asrd = authSchoolRunningDateService.queryAuthSchoolRunningDataBySchoolId(schoolId, loginType);
		if(asrd!=null){
			rd.setAuthSchoolRunningData(asrd);
			String pid = asrd.getPid();
			List<AuthSchoolRunningMap> asrm = authSchoolRunningDateService.queryAuthSchoolRunningMapByItemId(pid);
			String CountryPlanTime="";
			String ProvincePlanTime ="";
			for(AuthSchoolRunningMap as : asrm){
				if(as.getType().equals("0"))
					CountryPlanTime+=as.getPlantime()+",";
				if(as.getType().equals("1"))
					ProvincePlanTime+=as.getPlantime()+",";
			}
			if(StringUtils.isNotBlank(CountryPlanTime))
				CountryPlanTime=CountryPlanTime.substring(0, CountryPlanTime.length()-1);
			if(StringUtils.isNotBlank(ProvincePlanTime))
				ProvincePlanTime=ProvincePlanTime.substring(0, ProvincePlanTime.length()-1);
			rd.setCountryPlanTime(CountryPlanTime);
			rd.setProvincePlanTime(ProvincePlanTime);
		}
		return toResponse(rd,ReturnCode.SUCCESS,"查询成功");
	}
	
	/**
	 * 修改数据
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/updateSchoolRunning" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> updateSchoolRunning(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		String schoolId = map.get("sid");
		String loginType = map.get("loginType");
		if(schoolId==null || StringUtils.isBlank(schoolId))
			return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校ID不能为空");
		if(loginType==null || StringUtils.isBlank(loginType))
			return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专业类型不能为空");
		try {
			AuthSchoolRunningData asrd = authSchoolRunningDateService.queryAuthSchoolRunningDataBySchoolId(schoolId, loginType);
			if(asrd==null)
				return toResponse(asrd,ReturnCode.FAIL,"还未填报,无法更新");
			String pid = asrd.getPid();
			authSchoolRunningDateService.deleteRunningMap(pid);//删除子表信息
			String schoolStartTime = map.get("schoolStartTime");
			String reorganizationTime = map.get("reorganizationTime");
			String schoolUpgradedCollegeTime = map.get("schoolUpgradedCollegeTime");
			String undergraduateSchoolTime = map.get("undergraduateSchoolTime");
			String undergraduateProfessionalStartTime = map.get("undergraduateProfessionalStartTime");
			String specialtyStartupTime = map.get("specialtyStartupTime");
			String status = map.get("status");
			String plantime = map.get("planTime");
			String planType = map.get("planType");
			if(schoolStartTime!=null && StringUtils.isNotBlank(schoolStartTime))
				asrd.setSchoolStartTime(schoolStartTime);
			if(reorganizationTime!=null && StringUtils.isNotBlank(reorganizationTime))
				asrd.setReorganizationTime(reorganizationTime);
			if(schoolUpgradedCollegeTime!=null && StringUtils.isNotBlank(schoolUpgradedCollegeTime))
				asrd.setSchoolUpgradedCollegeTime(schoolUpgradedCollegeTime);
			if(undergraduateSchoolTime!=null && StringUtils.isNotBlank(undergraduateSchoolTime))
				asrd.setUndergraduateSchoolTime(undergraduateSchoolTime);
			if(undergraduateProfessionalStartTime!=null && StringUtils.isNotBlank(undergraduateProfessionalStartTime))
				asrd.setUndergraduateProfessionalStartTime(undergraduateProfessionalStartTime);
			if(specialtyStartupTime!=null && StringUtils.isNotBlank(specialtyStartupTime))
				asrd.setSpecialtyStartupTime(specialtyStartupTime);
			if(status!=null && StringUtils.isNotBlank(status))
				asrd.setStatus(status);
			authSchoolRunningDateService.insertAuthSchoolRunningData(asrd);
			if(asrd.getPid()!=null && plantime!=null && StringUtils.isNotBlank(plantime)){
				String[] plantimelist = plantime.split(",");
				String[] plantypelist = planType.split(",");
				for(int i =0;i<plantimelist.length;i++){
					AuthSchoolRunningMap asrm = new AuthSchoolRunningMap();
					asrm.setPlantime(plantimelist[i]);
					asrm.setSrid(asrd.getPid());
					asrm.setType(plantypelist[i]);
					authSchoolRunningDateService.insertRunningMap(asrm);
				}
			}
			return toResponse(asrd,ReturnCode.SUCCESS,"更新成功");
		} catch (Exception e) {
			// TODO: handle exception
			log.error(e);
			return toResponse(null,ReturnCode.FAIL,"更新失败");
		}
		
	}
	
	/******************************************************************************************************************/
	
	/**
	 * 新增办学数据
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/insertschoolRunning1" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> insertschoolRunning1(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		AuthSchoolRunningData asrd = new AuthSchoolRunningData();
		try{
			String sid = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==sid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登陆");
			}
			String subject = (String) request.getSession().getAttribute(SessionUser.SESSION_STATUS);//学科
			
			
			String schoolStartTime = map.get("schoolStartTime");
			String reorganizationTime = map.get("reorganizationTime");
			String schoolUpgradedCollegeTime = map.get("schoolUpgradedCollegeTime");
			String undergraduateSchoolTime = map.get("undergraduateSchoolTime");
			String undergraduateProfessionalStartTime = map.get("undergraduateProfessionalStartTime");
			String specialtyStartupTime = map.get("specialtyStartupTime");
			String remark1 = map.get("remark1");
			String remark2 = map.get("remark2");
			String remark3 = map.get("remark3");
			String remark4 = map.get("remark4");
			String remark5 = map.get("remark5");
			String remark6 = map.get("remark6");
			String remark7 = map.get("remark7");
			String remark8 = map.get("remark8");
			String status ="0";
			String plantime = map.get("planTime");
			String planType = map.get("planType");
			/*if(schoolStartTime==null || StringUtils.isBlank(schoolStartTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校创办时间不能为空");*/
			/*if(reorganizationTime==null || StringUtils.isBlank(reorganizationTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校合并或重组时间");
			if(schoolUpgradedCollegeTime==null || StringUtils.isBlank(schoolUpgradedCollegeTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校由中师升格专科时间");
			if(undergraduateSchoolTime==null || StringUtils.isBlank(undergraduateSchoolTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校由专科升格本科时间");
			if(undergraduateProfessionalStartTime==null || StringUtils.isBlank(undergraduateProfessionalStartTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"本科专业开办时间");*/
			if(specialtyStartupTime==null || StringUtils.isBlank(specialtyStartupTime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专科专业开办时间");
			if(sid==null || StringUtils.isBlank(sid))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"学校ID不能为空");
			
			/*if(plantime==null || StringUtils.isBlank(plantime))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"计划时间不能为空");
			if(planType==null || StringUtils.isBlank(planType))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"计划类型不能为空");*/
			String remark = remark1 + "#" +remark2+"#" +remark3+ "#" +remark4+ "#" +remark5+ "#" +remark6+ "#" +remark7+ "#" +remark8; 
			asrd.setCreatetime(sdf.format(new Date()));
			asrd.setLoginType(subject);
			asrd.setReorganizationTime(reorganizationTime);
			asrd.setSchoolStartTime(schoolStartTime);
			asrd.setSchoolUpgradedCollegeTime(schoolUpgradedCollegeTime);
			asrd.setSid(sid);
			asrd.setSpecialtyStartupTime(specialtyStartupTime);
			asrd.setStatus(status);
			asrd.setUndergraduateProfessionalStartTime(undergraduateProfessionalStartTime);
			asrd.setUndergraduateSchoolTime(undergraduateSchoolTime);
			asrd.setRemark(remark);
			authSchoolRunningDateService.insertAuthSchoolRunningData(asrd);
			if(asrd.getPid()!=null && plantime!=null && StringUtils.isNotBlank(plantime)){
				String[] plantimelist = plantime.split(",");
				String[] plantypelist = planType.split(",");
				for(int i =0;i<plantimelist.length;i++){
					AuthSchoolRunningMap asrm = new AuthSchoolRunningMap();
					asrm.setPlantime(plantimelist[i]);
					asrm.setSrid(asrd.getPid());
					asrm.setType(plantypelist[i]);
					authSchoolRunningDateService.insertRunningMap(asrm);
				}
			}
			AuthSchool as = authSchoolService.queryAuthSchoolInfoBypid(sid);
					
			asrd.setLoginType(subject);
			
			if("1".equals(status)){
				if("1101".equals(subject) ){ //如果是理科
					if(as.getScience().equals("2"))  //如果是登陆过 
						as.setScience("4");
					if(as.getScience().equals("3"))   //如果填写过基础数据状态表
						as.setScience("5");
				}
				if("1102".equals(subject) ){ //如果是文科
					if(as.getLiberalarts().equals("2"))  //如果是登陆过 
						as.setLiberalarts("4");
					if(as.getLiberalarts().equals("3"))   //如果填写过基础数据状态表
						as.setLiberalarts("5");
				}
				if("1103".equals(subject) ){ //如果是整体申报
					if(as.getWholeDeclaration().equals("2"))  //如果是登陆过 
						as.setWholeDeclaration("4");
					if(as.getWholeDeclaration().equals("3"))   //如果填写过基础数据状态表
						as.setWholeDeclaration("5");
				}
			}
			authSchoolService.updateAuthSchoolInfo(as);
			return toResponse(asrd,ReturnCode.SUCCESS,"新增成功");
		}catch(Exception e){
			log.error(e);
			return toResponse(null,ReturnCode.FAIL,"新增失败");
		}
		
	}
	
	@RequestMapping(value = "/querySchoolRunningBySchoolId1" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> querySchoolRunningBySchoolId1(HttpServletRequest request) throws SQLException{
		String sid = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		if(null==sid){
			return toResponse(null,ReturnCode.NOLOGIN,"未登陆");
		}
		String subject = (String) request.getSession().getAttribute(SessionUser.SESSION_STATUS);//学科
		
		RunningData rd = new RunningData();
		AuthSchoolRunningData asrd = authSchoolRunningDateService.queryAuthSchoolRunningDataBySchoolId(sid, subject);
		if(null!=asrd){
			rd.setAuthSchoolRunningData(asrd);
			String pid = asrd.getPid();
			List<AuthSchoolRunningMap> asrm = authSchoolRunningDateService.queryAuthSchoolRunningMapByItemId(pid);
			String CountryPlanTime="";
			String ProvincePlanTime ="";
			for(AuthSchoolRunningMap as : asrm){
				if(as.getType().equals("0"))
					CountryPlanTime+=as.getPlantime()+",";
				if(as.getType().equals("1"))
					ProvincePlanTime+=as.getPlantime()+",";
			}
			if(StringUtils.isNotBlank(CountryPlanTime))
				CountryPlanTime=CountryPlanTime.substring(0, CountryPlanTime.length()-1);
			if(StringUtils.isNotBlank(ProvincePlanTime))
				ProvincePlanTime=ProvincePlanTime.substring(0, ProvincePlanTime.length()-1);
			rd.setCountryPlanTime(CountryPlanTime);
			rd.setProvincePlanTime(ProvincePlanTime);
		}
		return toResponse(rd,ReturnCode.SUCCESS,"查询成功");
	}
	
	/**
	 * 修改数据
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/updateSchoolRunning1" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> updateSchoolRunning1(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		String sid = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		if(null==sid){
			return toResponse(null,ReturnCode.NOLOGIN,"未登陆");
		}
		String subject = (String) request.getSession().getAttribute(SessionUser.SESSION_STATUS);//学科
		try {
			AuthSchoolRunningData asrd = authSchoolRunningDateService.queryAuthSchoolRunningDataBySchoolId(sid, subject);
			if(null==asrd){
				asrd = new AuthSchoolRunningData();
			}			
			String schoolStartTime = map.get("schoolStartTime");
			String reorganizationTime = map.get("reorganizationTime");
			String schoolUpgradedCollegeTime = map.get("schoolUpgradedCollegeTime");
			String undergraduateSchoolTime = map.get("undergraduateSchoolTime");
			String undergraduateProfessionalStartTime = map.get("undergraduateProfessionalStartTime");
			String specialtyStartupTime = map.get("specialtyStartupTime");
			String status = map.get("status");
			String plantime = map.get("planTime");
			String planType = map.get("planType");
			String pid = asrd.getPid();
			String remark1 = map.get("remark1");
			String remark2 = map.get("remark2");
			String remark3 = map.get("remark3");
			String remark4 = map.get("remark4");
			String remark5 = map.get("remark5");
			String remark6 = map.get("remark6");
			String remark7 = map.get("remark7");
			String remark8 = map.get("remark8");
			if(StringUtils.isNotBlank(schoolStartTime))
				asrd.setSchoolStartTime(schoolStartTime);
			if(StringUtils.isNotBlank(reorganizationTime))
				asrd.setReorganizationTime(reorganizationTime);
			if(StringUtils.isNotBlank(schoolUpgradedCollegeTime))
				asrd.setSchoolUpgradedCollegeTime(schoolUpgradedCollegeTime);
			if(StringUtils.isNotBlank(undergraduateSchoolTime))
				asrd.setUndergraduateSchoolTime(undergraduateSchoolTime);
			if(StringUtils.isNotBlank(undergraduateProfessionalStartTime))
				asrd.setUndergraduateProfessionalStartTime(undergraduateProfessionalStartTime);
			if(StringUtils.isNotBlank(specialtyStartupTime))
				asrd.setSpecialtyStartupTime(specialtyStartupTime);
			if(StringUtils.isNotBlank(status))
				asrd.setStatus(status);
			String remark = remark1 + "#" +remark2+"#" +remark3+ "#" +remark4+ "#" +remark5+ "#" +remark6+ "#" +remark7+ "#" +remark8; 
			asrd.setRemark(remark);
			authSchoolRunningDateService.insertAuthSchoolRunningData(asrd);
			
			authSchoolRunningDateService.deleteAuthSchoolRunningMapBySRId(asrd.getPid());
			if(null!=asrd.getPid()){
				String[] plantimelist = plantime.split(",");
				String[] plantypelist = planType.split(",");
				for(int i =0;i<plantimelist.length;i++){		
					AuthSchoolRunningMap asrm = new AuthSchoolRunningMap();
					asrm.setPlantime(plantimelist[i]);
					asrm.setSrid(asrd.getPid());
					asrm.setType(plantypelist[i]);
					authSchoolRunningDateService.insertRunningMap(asrm);
				}
				
			}
			return toResponse(asrd,ReturnCode.SUCCESS,"更新成功");
		} catch (Exception e) {
			log.error(e);
			return toResponse(null,ReturnCode.FAIL,"更新失败");
		}
		
	}
	@RequestMapping(value = "/querySchoolRunningBySchoolId2" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> querySchoolRunningBySchoolId2(HttpServletRequest request,@RequestParam String schoolid) throws SQLException{
		RunningData rd = new RunningData();
		AuthSchoolRunningData asrd = authSchoolRunningDateService.queryAuthSchoolRunningDataBySchoolId(schoolid, null);
		if(null!=asrd){
			rd.setAuthSchoolRunningData(asrd);
			String pid = asrd.getPid();
			List<AuthSchoolRunningMap> asrm = authSchoolRunningDateService.queryAuthSchoolRunningMapByItemId(pid);
			String CountryPlanTime="";
			String ProvincePlanTime ="";
			for(AuthSchoolRunningMap as : asrm){
				if(as.getType().equals("0"))
					CountryPlanTime+=as.getPlantime()+",";
				if(as.getType().equals("1"))
					ProvincePlanTime+=as.getPlantime()+",";
			}
			if(StringUtils.isNotBlank(CountryPlanTime))
				CountryPlanTime=CountryPlanTime.substring(0, CountryPlanTime.length()-1);
			if(StringUtils.isNotBlank(ProvincePlanTime))
				ProvincePlanTime=ProvincePlanTime.substring(0, ProvincePlanTime.length()-1);
			rd.setCountryPlanTime(CountryPlanTime);
			rd.setProvincePlanTime(ProvincePlanTime);
		}else{
			asrd=new AuthSchoolRunningData();
			rd.setAuthSchoolRunningData(asrd);
		}
		
		return toResponse(rd,ReturnCode.SUCCESS,"办学数据成功");
	}
	
	
}
